package top.novel.factory;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NotNull;
import top.novel.ioc.factory.StrategyModule;
import top.novel.ui.NovelForm;

/**
 * @author xuhainan
 * @date 2022/8/8 17:03
 * @region hefei
 */
public class NovelFormFactory implements ToolWindowFactory {

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        Injector injector = Guice.createInjector(new StrategyModule());

        NovelForm noteListWindow = new NovelForm(project, toolWindow, injector);
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        Content content = contentFactory.createContent(noteListWindow.getNovelPanel(), "Novel", false);
        toolWindow.getContentManager().addContent(content);
    }

}
